package com.lh.gomoku.implement;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;

import com.lh.gomoku.interfaces.ChessBoard;
import com.lh.gomoku.interfaces.ChessGame;
import com.lh.gomoku.interfaces.ChessPieces;
import com.lh.gomoku.interfaces.ChessPlayer;

public class GomokuChessPlayer implements ChessPlayer {

	public static final String Y_BLACK = "black";
	public static final String Y_WHITE = "white";
	String name;
	String yellow;
	private boolean isReady;
	
	Socket socket;
	BufferedReader reader;
	BufferedWriter writer;
	
	public GomokuChessPlayer(String name){
		this.name = name;
	}
	
	public void sueForPeace() {
		
	}

	public void giveUp() {
		
	}

	public void takeBack() {
		
	}

	public void piecesUnder(ChessPieces piece, ChessGame cb) {
		cb.piecesUnder(piece);
		GomokuChessGame gcg = (GomokuChessGame)cb;
		if(gcg.getGcj().checkGame(gcg)){
			gcg.commit();
		}
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getYellow() {
		return yellow;
	}

	public void setYellow(String yellow) {
		this.yellow = yellow;
	}

	public void setReady() {
		// TODO Auto-generated method stub
		isReady = true;
	}
	public boolean isReady(){
		return isReady;
	}

	public Socket getSocket() {
		return socket;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
		try {
			this.reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			this.writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public BufferedReader getReader() {
		return reader;
	}

	public BufferedWriter getWriter() {
		return writer;
	}

}
